import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router = new Router({
  mode: 'history',
  routes: [
    {
      path: '/', // bind list
      name: 'home',
      component: () => import(/* webpackChunkName: "main" */ './views/Home.vue')
    },
    {
      path: '/message/list', // bind list
      name: 'list',
      component: () => import(/* webpackChunkName: "main" */ './views/message/list.vue')
    },
    {
      path: '/pay/wechat', // bind Agency
      name: 'paywechat',
      component: () => import(/* webpackChunkName: "main" */ './views/pay/Wechat.vue')
    },    {
      path: '/pay/agency', // bind Agency
      name: 'payagency',
      component: () => import(/* webpackChunkName: "main" */ './views/pay/Agency.vue')
    },
    {
      path: '/bind/phone', // bind
      name: 'bindphone',
      component: () => import(/* webpackChunkName: "main" */ './views/BindPhone.vue')
    },
    {
      path: '/staff/login',
      name: 'stafflogin',
      component: () => import(/* webpackChunkName: "main" */ './views/staff/Login.vue')
    },
    {
      path: '/staff/workorder/list',
      name: 'staffworkorderlist',
      component: () => import(/* webpackChunkName: "main" */ './views/staff/WorkOrderList.vue')
    },
    {
      path: '/staff/workorder/handle',
      name: 'WorkOrderHandle',
      component: () => import(/* webpackChunkName: "main" */ './views/chat/WorkOrderHandle.vue')
    },
    {
      path: '/resetpassword',
      name: 'resetpassword',
      component: () => import(/* webpackChunkName: "main" */ './views/RsetPass.vue')
    },
    {
      path: '/oauth',
      name: 'oauth',
      component: () => import(/* webpackChunkName: "main" */ './views/Oauth.vue')
    },
    {
      path: '/oauth/wechat',
      name: 'oauthwechat',
      component: () => import(/* webpackChunkName: "main" */ './views/OauthWechat.vue')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import(/* webpackChunkName: "main" */ './views/Login.vue')
    },
    {
      path: '/register',
      name: 'register',
      component: () => import(/* webpackChunkName: "main" */ './views/Register.vue')
    },
    {
      path: '/user/center',
      name: 'usercenter',
      component: () => import(/* CreateOrder: "main" */ './views/user/Center.vue')
    },
    {
      path: '/user/member',//management
      name: 'usermember',
      component: () => import(/* webpackChunkName: "main" */ './views/user/Member.vue')
    },
    {
      path: '/pay/member',//management
      name: 'paymember',
      component: () => import(/* webpackChunkName: "main" */ './views/pay/Member.vue')
    },
    {
      path: '/pay/wechat',//management
      name: 'paywechat',
      component: () => import(/* webpackChunkName: "main" */ './views/pay/Wechat.vue')
    },
    {
      path: '/order/management',//management
      name: 'ordermanagement',
      component: () => import(/* webpackChunkName: "main" */ './views/order/Management.vue')
    },
    {
      path: '/underwriter/from',//management
      name: 'underwriterfrom',
      component: () => import(/* webpackChunkName: "main" */ './views/underwriter/From.vue')
    },
    {
      path: '/underwriter/message',//management
      name: 'underwritermessage',
      component: () => import(/* webpackChunkName: "main" */ './views/underwriter/Message.vue')
    },
    {
      path: '/underwriter/create/order',
      name: 'underwritercreateorder',
      component: () => import(/* webpackChunkName: "main" */ './views/underwriter/CreateOrder.vue')
    },
    {
      path: '/workorder/from',//management
      name: 'workorderfrom',
      component: () => import(/* webpackChunkName: "main" */ './views/workorder/From.vue')
    },
    {
      path: '/workorder/message',//management
      name: 'workordermessage',
      component: () => import(/* webpackChunkName: "main" */ './views/workorder/Message.vue')
    },
    {
      path: '/workorder/create/order',
      name: 'workordercreateorder',
      component: () => import(/* webpackChunkName: "main" */ './views/workorder/CreateOrder.vue')
    },
    {
      path: '/chat',
      name: 'chat',
      component: () => import(/* webpackChunkName: "main" */ './views/chat/chat.vue')
    },
  ],
})
 // afterEach // beforeEach
router.afterEach((to) => {
  
  if(window.location.pathname + window.location.search != to.fullPath){ // 微信ISO 的坑
    var u = navigator.userAgent;
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if(isiOS){
      window.location.href = to.fullPath
    }
  }
})
export default router
